﻿using System;

namespace Samples.Radio.Agent.Model
{
    public class TrackModel
    {
        public bool NowPlaying { get; set; }
        public string Title { get; set; }
        public string TrackName
        {
            get { return Title; }
        }
        public string Album { get; set; }
        public string Artist { get; set; }
        public TimeSpan Duration { get; set; }
        public DateTime PlayedTime { get; set; }
        public string TrackImageUrl { get; set; }

        public TrackModel()
        {
            NowPlaying = false;
            Title = "";
            Album = "";
            Artist = "";
            Duration = new TimeSpan(0);
            PlayedTime = DateTime.Now;
            TrackImageUrl = "";
        }

        /// <summary>
        /// Object equals is based on title and artist being the same
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj is TrackModel)
            {
                return Title.Equals((obj as TrackModel).Title) &&
                    Artist.Equals((obj as TrackModel).Artist);
            }

            return false;
        }

        /// <summary>
        /// Hashcode is based on title and artist
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            return (Title + Artist).GetHashCode();
        }
    }
}
